﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using COMOSOFT.Class;
using DevExpress.XtraEditors;

namespace COMOSOFT.Main
{
    public partial class FrmChangePassword : Form
    {
        ClassShare cls = new ClassShare("FrmChangePassword");
        public FrmChangePassword()
        {
            InitializeComponent();
        }
        private int ChangePassword(string oldpass, string newpass)
        {          
            return cls.UpdateData("sp_ChangePassword",new string[]{"@EID","@OldPass","@NewPass"},new object[]{ClassShare.Usid,oldpass,newpass});
        }
        private void btnChange_Click(object sender, EventArgs e)
        {
            int exc=ChangePassword(txtOldpass.Text.Trim(),txtNewpass.Text.Trim());
            if (exc != 0)
            {
                XtraMessageBox.Show("Change Password Successfully!");
                this.Close();
            }
            else
            {
                XtraMessageBox.Show("Change password unsuccessfully! Please check your old password again!","ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtNewpass.Text = "";
                txtOldpass.Text = "";
                txtOldpass.Focus();
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmChangePassword_Load(object sender, EventArgs e)
        {
            AcceptButton = btnChange;
        }
    }
}
